<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/blog/css/main.css">


<link rel="stylesheet" href="/blog/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"dttx123.gitee.io","root":"/blog/","scheme":"Gemini","version":"8.0.0-rc.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="IT">
<meta property="og:type" content="website">
<meta property="og:title" content="Starry Night">
<meta property="og:url" content="http://dttx123.gitee.io/page/4/index.html">
<meta property="og:site_name" content="Starry Night">
<meta property="og:description" content="IT">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="大春哥">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://dttx123.gitee.io/page/4/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>Starry Night</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
        <span class="toggle-line toggle-line-first"></span>
        <span class="toggle-line toggle-line-middle"></span>
        <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/blog/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Starry Night</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">这就朕为你打下的江山</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/blog/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/blog/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/blog/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/blog/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/blog/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://dttx123.gitee.io/2016/08/07/webAPI/04/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.jpg">
      <meta itemprop="name" content="大春哥">
      <meta itemprop="description" content="IT">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Starry Night">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2016/08/07/webAPI/04/" class="post-title-link" itemprop="url">webAPI04</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2016-08-07 00:00:00" itemprop="dateCreated datePublished" datetime="2016-08-07T00:00:00+08:00">2016-08-07</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-05-13 11:06:59" itemprop="dateModified" datetime="2020-05-13T11:06:59+08:00">2020-05-13</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/dom%E6%93%8D%E4%BD%9C/" itemprop="url" rel="index"><span itemprop="name">dom操作</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="注册事件的两种方式"><a href="#注册事件的两种方式" class="headerlink" title="注册事件的两种方式"></a>注册事件的两种方式</h1><h2 id="on-事件名称"><a href="#on-事件名称" class="headerlink" title="on+事件名称"></a>on+事件名称</h2><blockquote>
<p>onclick、onmouseover这种on+事件名称的方式注册事件几乎所有的浏览器都支持。</p>
</blockquote>
<p>注册事件：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">box.onclick = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">	<span class="comment">//事件处理程序	</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>移除事件：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">box.onclick = <span class="literal">null</span>;</span><br></pre></td></tr></table></figure>

<p>on+事件名称注册事件的缺点：</p>
<p>同一个元素同一类型的事件，只能注册一个，如果注册了多个，会出现覆盖问题。</p>
<h2 id="注册事件的新方式"><a href="#注册事件的新方式" class="headerlink" title="注册事件的新方式"></a>注册事件的新方式</h2><p><strong>addEventListener与removeEventListener</strong></p>
<blockquote>
<p>现代浏览器支持的注册事件的新方式，这种方式注册的事件不会出现覆盖问题。</p>
</blockquote>
<p>addEventListener的语法</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//第一个参数：事件的类型：click mouseover</span></span><br><span class="line"><span class="comment">//第二个参数：函数，监听者，每次点击，这个函数就执行。</span></span><br><span class="line"><span class="comment">//第三个参数：是否使用捕获，默认为false，表示冒泡</span></span><br><span class="line">addEventListener(type, func, useCapture);</span><br></pre></td></tr></table></figure>

<p><strong>tips：如果想要让你注册的事件能够移除，不能使用匿名函数。</strong> </p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">fn1</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    alert(<span class="string">"hehe"</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//如果想让注册的事件能移除，不能用匿名函数。</span></span><br><span class="line">box.addEventListener(<span class="string">"click"</span>, fn1, <span class="literal">false</span>);</span><br></pre></td></tr></table></figure>

<p>removeEventListen的语法</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//第一个参数：参数类型</span></span><br><span class="line"><span class="comment">//第二个参数：要移除的那个函数</span></span><br><span class="line"><span class="comment">//第三个参数：false</span></span><br><span class="line">removeEventListener(type, func, useCapture);</span><br></pre></td></tr></table></figure>

<p><strong>attachEvent与detachEvent（了解）</strong></p>
<blockquote>
<p>IE678不支持addEventListener与removeEventListen两个方法，但是支持attachEvent与detachEvnet</p>
</blockquote>
<p>attachEvent的用法：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//type:事件类型   需要加上on   onclick  onmouseenter</span></span><br><span class="line"><span class="comment">//func:需要执行的那个事件</span></span><br><span class="line">attachEvent(type, func)</span><br></pre></td></tr></table></figure>

<p>detachEvent的用法</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//type:事件类型   需要加上on   onclick  onmouseenter</span></span><br><span class="line"><span class="comment">//func:需要执行的那个事件</span></span><br><span class="line">detachEvent(type, func)</span><br></pre></td></tr></table></figure>



<h1 id="事件对象"><a href="#事件对象" class="headerlink" title="事件对象"></a>事件对象</h1><h2 id="事件对象的概述"><a href="#事件对象的概述" class="headerlink" title="事件对象的概述"></a>事件对象的概述</h2><blockquote>
<p>在触发某个事件的时候，都会产生一个事件对象Event，这个对象中包含所有与事件相关的一些信息，包括触发事件的元素，事件的类型以及其他与事件相关的信息。</p>
</blockquote>
<p>鼠标事件触发时，事件对象中会包含鼠标的位置信息。</p>
<p>键盘事件触发时，事件对象中会包含按下的键相关的信息。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">每一个事件在触发时，都会产生一个事件对象。</span><br><span class="line">你见或者不见，我就在那里，不悲不喜。</span><br><span class="line">你爱或者不爱，爱就在那里，不增不减。</span><br><span class="line">你用或者不用，我都会给你，不离不弃。</span><br></pre></td></tr></table></figure>

<h2 id="获取事件对象"><a href="#获取事件对象" class="headerlink" title="获取事件对象"></a>获取事件对象</h2><blockquote>
<p>既然事件对象中存储了这么多的信息，我们首先需要做的就是获取到这个事件对象。</p>
</blockquote>
<p>获取事件对象非常的简单，只需要在注册事件的时候，指定一个形参即可。这个形参就是我们想要获取到的事件对象。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">btn.onclick = <span class="function"><span class="keyword">function</span>(<span class="params">event</span>)</span>&#123;</span><br><span class="line">    <span class="comment">//event就是事件对象，里面包含了事件触发时的一些信息。</span></span><br><span class="line">	<span class="built_in">console</span>.log(event);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="事件对象的常用属性"><a href="#事件对象的常用属性" class="headerlink" title="事件对象的常用属性"></a>事件对象的常用属性</h2><blockquote>
<p>事件对象中有很多很多的属性，但是很多属性并不常用。我们经常用到的是<strong><em>鼠标位置信息</em></strong> 和<strong><em>键盘码</em></strong>  相关的信息。</p>
</blockquote>
<p>记录了鼠标位置信息的相关属性</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">screenX与screenY：光标相对于屏幕左上角的水平位置与垂直位置。</span><br><span class="line">clientX与clientY：光标相对于可视区左上角的水平位置和垂直位置。</span><br><span class="line">pageX与pageY：光标相对于网页（文档<span class="built_in">document</span>）左上角的水平位置与垂直位置（推荐使用）</span><br></pre></td></tr></table></figure>

<p>【案例:让小天使飞.html】</p>
<p>记录了键盘码的属性</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">获取键盘码: 在键盘事件中，通过e.keyCode可以获取到按下的键盘码</span><br></pre></td></tr></table></figure>

<p><img src="/blog/2016/08/07/webAPI/04/keyCode.jpg" alt="键盘码"></p>
<p>【微博评论-添加回车发送功能】</p>
<h2 id="offset系列"><a href="#offset系列" class="headerlink" title="offset系列"></a>offset系列</h2><h3 id="offsetHeight与offsetWidth"><a href="#offsetHeight与offsetWidth" class="headerlink" title="offsetHeight与offsetWidth"></a>offsetHeight与offsetWidth</h3><blockquote>
<p>offsetHeight与offsetWidth</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> 获取的是元素真实的高度和宽度</span><br><span class="line"><span class="number">2.</span> 获取到的是数值类型，方便计算</span><br><span class="line"><span class="number">3.</span> offsetHeight与offsetWidth是只读属性，不能设置。</span><br></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">获取宽度和高度offsetWidth与offsetHeight</span><br></pre></td></tr></table></figure>

<h3 id="offsetParent"><a href="#offsetParent" class="headerlink" title="offsetParent"></a>offsetParent</h3><blockquote>
<p>parentNode和offsetParent</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> parentNode始终是父元素</span><br><span class="line"><span class="number">2.</span> offsetParent是离当前元素最近的定位元素(absolute、relative)，如果没有，那就找body</span><br></pre></td></tr></table></figure>

<h3 id="offsetLeft与offsetTop"><a href="#offsetLeft与offsetTop" class="headerlink" title="offsetLeft与offsetTop"></a>offsetLeft与offsetTop</h3><blockquote>
<p>offsetLeft: 自身左侧到offsetParent左侧的距离；</p>
<p>offsetTop:自身顶部到offsetParent顶部的距离；</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>	元素自身与offsetParent真实的距离</span><br><span class="line"><span class="number">2.</span>	获取到的是数值类型，方便计算</span><br><span class="line"><span class="number">3.</span>	只读属性，只能获取，不能设置</span><br></pre></td></tr></table></figure>

<p> <img src="/blog/2016/08/07/webAPI/04/1.png" alt="1"></p>
<h2 id="拖拽特效"><a href="#拖拽特效" class="headerlink" title="拖拽特效"></a>拖拽特效</h2><p>【可拖拽的盒子.html】</p>
<h2 id="放大镜效果（案例）"><a href="#放大镜效果（案例）" class="headerlink" title="放大镜效果（案例）"></a>放大镜效果（案例）</h2><blockquote>
<p>放大镜在开发中是一个很常见的特效，但是所有的放大镜的实现效果都是一样。</p>
</blockquote>
<p>【案例-07-放大镜特效】</p>
<p>实现思路：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> 给box注册onmouseover事件，让big和mask显示</span><br><span class="line"><span class="number">2.</span> 给box注册onmouseout事件，让big和mask隐藏</span><br><span class="line"><span class="number">3.</span> 给box注册onmousemove事件，获取鼠标在box中的位置，让mask跟着移动</span><br><span class="line"><span class="number">4.</span> 限定mask的移动范围</span><br><span class="line"><span class="number">5.</span> 根据比例让bigImg跟着移动</span><br></pre></td></tr></table></figure>



<h1 id="事件流"><a href="#事件流" class="headerlink" title="事件流"></a>事件流</h1><h2 id="事件冒泡"><a href="#事件冒泡" class="headerlink" title="事件冒泡"></a>事件冒泡</h2><blockquote>
<p>当一个元素的事件被触发时，同样的事件将会在该元素的所有祖先元素中依次被触发。这一过程被称为事件冒泡。</p>
</blockquote>
<p>说白了就是：当我们触发了子元素的某个事件后，父元素对应的事件也会触发。</p>
<p> <img src="/blog/2016/08/07/webAPI/04/bubble.png" alt="bubble"></p>
<h2 id="事件捕获（了解）"><a href="#事件捕获（了解）" class="headerlink" title="事件捕获（了解）"></a>事件捕获（了解）</h2><blockquote>
<p>事件捕获是火狐浏览器提出来的，IE678不支持事件捕获（基本上，我们都是用事件冒泡）<br>事件的处理将从DOM层次的根开始，而不是从触发事件的目标元素开始，事件被从目标元素的所有祖先元素依次往下传递</p>
</blockquote>
<p> <img src="/blog/2016/08/07/webAPI/04/capture.png" alt="capture"></p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//当addEventListener第三个参数为true时，表示事件捕获</span></span><br><span class="line">arr[i].addEventListener(<span class="string">"click"</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="built_in">console</span>.log(<span class="keyword">this</span>);</span><br><span class="line">&#125;,<span class="literal">true</span>);</span><br></pre></td></tr></table></figure>

<h2 id="事件的三个阶段"><a href="#事件的三个阶段" class="headerlink" title="事件的三个阶段"></a>事件的三个阶段</h2><ol>
<li><p>事件的捕获阶段</p>
</li>
<li><p>事件的目标阶段（触发自己的事件）</p>
</li>
<li><p>事件的冒泡阶段</p>
<p><img src="/blog/2016/08/07/webAPI/04/three.png" alt="three"></p>
</li>
</ol>
<p>事件有三个阶段，首先发生的是捕获阶段，然后是目标阶段，最后才是冒泡阶段，让<code>addEventLinstener</code>第三个参数为true时，表示该事件在捕获阶段发生，如果第三个参数为false，表示该事件在冒泡阶段发生。</p>
<h2 id="阻止事件冒泡"><a href="#阻止事件冒泡" class="headerlink" title="阻止事件冒泡"></a>阻止事件冒泡</h2><blockquote>
<p>通过e.stopPropagation()方法可以阻止事件冒泡</p>
</blockquote>
<p>【案例：登录框】</p>
<h2 id="事件补充：阻止浏览器默认行为"><a href="#事件补充：阻止浏览器默认行为" class="headerlink" title="事件补充：阻止浏览器默认行为"></a>事件补充：阻止浏览器默认行为</h2><blockquote>
<p>阻止浏览器默认行为除了使用 return false。</p>
<p>还可以通过 e.preventDefault() 可以阻止浏览器的默认行为</p>
</blockquote>
<h1 id="常见的事件"><a href="#常见的事件" class="headerlink" title="常见的事件"></a>常见的事件</h1><blockquote>
<p>常见的鼠标事件</p>
</blockquote>
<p>onmousedown:鼠标按下事件</p>
<p>onmouseup:鼠标弹起事件</p>
<p>onclick:单击事件</p>
<p>ondblclick：双击事件</p>
<p>onmouseover：鼠标经过事件</p>
<p>onmouseout：鼠标离开事件</p>
<p>onmousemove：鼠标移动事件</p>
<p>onfocus：鼠标获得焦点事件</p>
<p>onblur：鼠标失去焦点事件</p>
<blockquote>
<p>常见的键盘事件</p>
</blockquote>
<p>onkeydown:键盘按下时触发</p>
<p>onkeyup:键盘弹起时触发</p>
<blockquote>
<p>对于鼠标事件，事件对象中有一系列的XY记录了鼠标的位置信息。</p>
<p>键盘事件中，事件对象有一个event.keyCode属性，记录了按下去的键的键盘码</p>
</blockquote>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://dttx123.gitee.io/2016/08/07/webAPI/03/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.jpg">
      <meta itemprop="name" content="大春哥">
      <meta itemprop="description" content="IT">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Starry Night">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2016/08/07/webAPI/03/" class="post-title-link" itemprop="url">webAPI03</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2016-08-07 00:00:00" itemprop="dateCreated datePublished" datetime="2016-08-07T00:00:00+08:00">2016-08-07</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-05-13 11:05:00" itemprop="dateModified" datetime="2020-05-13T11:05:00+08:00">2020-05-13</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/dom%E6%93%8D%E4%BD%9C/" itemprop="url" rel="index"><span itemprop="name">dom操作</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="节点操作"><a href="#节点操作" class="headerlink" title="节点操作"></a>节点操作</h1><h2 id="节点查找"><a href="#节点查找" class="headerlink" title="节点查找"></a>节点查找</h2><h3 id="孩子节点"><a href="#孩子节点" class="headerlink" title="孩子节点"></a>孩子节点</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//childNodes:获取所有的孩子节点（包括了元素节点和其他很多类型的节点）</span></span><br><span class="line"><span class="comment">//children:获取所有的子元素（用途很广泛）</span></span><br><span class="line"><span class="comment">//firstChild //第一个子节点</span></span><br><span class="line"><span class="comment">//firstElementChild //第一个子元素</span></span><br><span class="line"><span class="comment">//lastChild //最后一个节点</span></span><br><span class="line"><span class="comment">//lastElementChild //最后一个子元素</span></span><br></pre></td></tr></table></figure>

<h3 id="兄弟节点"><a href="#兄弟节点" class="headerlink" title="兄弟节点"></a>兄弟节点</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//1. nextSibling:下一个兄弟节点</span></span><br><span class="line"><span class="comment">//2. nextElementSibling:下一个兄弟元素</span></span><br><span class="line"><span class="comment">//3. previousSibling//上一个兄弟节点</span></span><br><span class="line"><span class="comment">//4. previousElementSibling //上一个兄弟元素</span></span><br></pre></td></tr></table></figure>

<h3 id="父节点"><a href="#父节点" class="headerlink" title="父节点"></a>父节点</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//1. parentNode:父节点</span></span><br></pre></td></tr></table></figure>

<p>【案例：隔行变色】</p>
<p>【案例：表单校验】</p>
<h3 id="onkeydown与onkeyup事件"><a href="#onkeydown与onkeyup事件" class="headerlink" title="onkeydown与onkeyup事件"></a>onkeydown与onkeyup事件</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> onkeydown: 当键盘按下时触发的事件</span><br><span class="line"><span class="number">2.</span> onkeyup: 键盘弹起时触发的事件</span><br><span class="line"></span><br><span class="line">注意：如果给文本框注册的是onkeydown事件，获取的value值是上一次的。</span><br></pre></td></tr></table></figure>



<h2 id="添加节点"><a href="#添加节点" class="headerlink" title="添加节点"></a>添加节点</h2><h3 id="appendChild"><a href="#appendChild" class="headerlink" title="appendChild"></a>appendChild</h3><p>语法：parent.appendChild(child)</p>
<p>parent: 调用者，父节点来调用</p>
<p>child:需要添加的那个孩子。</p>
<p>作用：把child添加到parent的孩子的最后面。</p>
<blockquote>
<p>如果添加的是页面中本来就存在的元素，是一个剪切的效果，原来的就不在了。</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> demo = <span class="built_in">document</span>.getElementById(<span class="string">"demo"</span>);</span><br><span class="line"><span class="keyword">var</span> box = <span class="built_in">document</span>.getElementById(<span class="string">"box"</span>);</span><br><span class="line">box.appendChild(demo);</span><br></pre></td></tr></table></figure>

<h3 id="insertBefore"><a href="#insertBefore" class="headerlink" title="insertBefore"></a>insertBefore</h3><p>语法：parent.insertBefore(child, refChild);</p>
<p>parent:必须要父节点来调用</p>
<p>child：需要添加的那个节点</p>
<p>refChild:添加到哪一个节点的前面。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> ul = <span class="built_in">document</span>.getElementById(<span class="string">"list"</span>);</span><br><span class="line"><span class="keyword">var</span> li = <span class="built_in">document</span>.createElement(<span class="string">"li"</span>);</span><br><span class="line">li.innerHTML = <span class="string">"骥骥"</span>;</span><br><span class="line"><span class="comment">//就是添加到子节点的最前面。</span></span><br><span class="line">ul.insertBefore(li, ul.children[<span class="number">0</span>]);</span><br></pre></td></tr></table></figure>



<h2 id="克隆节点"><a href="#克隆节点" class="headerlink" title="克隆节点"></a>克隆节点</h2><p>语法：var newNode = node.cloneNode(deep)</p>
<p>功能：在内存中克隆一份节点</p>
<p>参数：deep</p>
<ul>
<li>false：默认值：是浅复制，只会复制标签，节点本身，不会复制节点的孩子。</li>
<li>true:深度复制，会复制标签，还会复制标签的所有内容 — <strong>常用</strong></li>
</ul>
<blockquote>
<ol>
<li>克隆出来的节点跟原来的节点没有关系了，修改了也不会相互影响。</li>
<li>如果克隆的节点带了id，我们需要给id重新设置一个值，不让id冲突</li>
</ol>
</blockquote>
<h2 id="删除节点"><a href="#删除节点" class="headerlink" title="删除节点"></a>删除节点</h2><p>语法：parent.removeChild(child);</p>
<p>功能：由父盒子调用，删除里面的一个子元素。</p>
<p>【案例：祝愿墙】 —  ondblclick：双击的时候触发</p>
<h2 id="创建节点（3种方式）"><a href="#创建节点（3种方式）" class="headerlink" title="创建节点（3种方式）"></a>创建节点（3种方式）</h2><h3 id="document-write（基本不用）"><a href="#document-write（基本不用）" class="headerlink" title="document.write（基本不用）"></a>document.write（基本不用）</h3><p>可以生成新的节点，但是不推荐使用。<strong><em>如果页面已经加载完成了，你还是用document.write写内容的话，会把之前的页面给覆盖掉</em></strong> </p>
<p>原理：页面从上往下加载的时候，会开启一个文档流，当页面加载完，文档流就会关闭。</p>
<p>document.write的本意就是在文档流上写入内容。如果页面没加载完成，文档流还是开着的，document.write直接在这个文档流上写东西</p>
<p>如果页面加载完成了，还是用document.write写东西，会重新开启一个新的文档流，往新的文档流上写东西，旧的文档流就被新的文档流覆盖了。</p>
<h3 id="innerHTML"><a href="#innerHTML" class="headerlink" title="innerHTML"></a>innerHTML</h3><p>innerHTML也可以创建节点</p>
<blockquote>
<p>innerHTML创建节点的时候有一个特点，如果原来有内容的话，使用innerHTML会把原先的内容给干掉。</p>
<p>慎用：很容易出现性能效率问题。</p>
</blockquote>
<h3 id="createElement"><a href="#createElement" class="headerlink" title="createElement"></a>createElement</h3><p>语法：var element = document.createElement(“tagName”);</p>
<p>作用：在内存里面创建了一个节点</p>
<p>返回：一个元素。 用途非常的广泛。</p>
<p>【案例：微博发布】</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://dttx123.gitee.io/2016/07/03/webAPI/02/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.jpg">
      <meta itemprop="name" content="大春哥">
      <meta itemprop="description" content="IT">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Starry Night">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2016/07/03/webAPI/02/" class="post-title-link" itemprop="url">webAPI 02</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2016-07-03 00:00:00" itemprop="dateCreated datePublished" datetime="2016-07-03T00:00:00+08:00">2016-07-03</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-05-13 11:25:06" itemprop="dateModified" datetime="2020-05-13T11:25:06+08:00">2020-05-13</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="标签的内容属性"><a href="#标签的内容属性" class="headerlink" title="标签的内容属性"></a>标签的内容属性</h1><blockquote>
<p>innerText和innerHTML属性都是用来获取和设置标签的内容的。但是二者还是有区别的。</p>
</blockquote>
<blockquote>
<p>innerHTML可以用于获取和设置标签的所有内容，包括标签和文本内容</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; innerHTML:内部的HTML</span><br><span class="line">&#x2F;&#x2F;  获取标签内容的时候，不管标签还是文本，都能获取到</span><br><span class="line">&#x2F;&#x2F;  innerHTML设置内容的时候，覆盖原来内容，标签也能生效，浏览器能解析这个标签。</span><br></pre></td></tr></table></figure>

<blockquote>
<p>innerText可以用于获取和设置标签的文本内容，会丢弃掉标签</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F;innerText:内部文本</span><br><span class="line">&#x2F;&#x2F;  获取标签内容的时候，只会获取文本，标签扔掉了</span><br><span class="line">&#x2F;&#x2F;  设置标签内容的时候，覆盖原来内容，对标签进行转义（目的：把标签直接当文本来用）</span><br></pre></td></tr></table></figure>

<p>二者的区别：</p>
<ul>
<li>innerHTML能够识别标签，标签能够生效</li>
<li>innerText只识别文本，标签会被转义</li>
</ul>
<h2 id="案例：美女相册"><a href="#案例：美女相册" class="headerlink" title="案例：美女相册"></a>案例：美女相册</h2><h1 id="表单属性操作"><a href="#表单属性操作" class="headerlink" title="表单属性操作"></a>表单属性操作</h1><blockquote>
<p>常见的表单属性有：disabled、type、value、checked、selected</p>
</blockquote>
<p>对于disabled、checked、selected三个属性来说，比较特殊。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">在标签中，只要指定了disabled属性，无论有值没值，都代表这个input是被禁用的。注意，标签的disabled仅仅是默认值。</span><br><span class="line">在DOM对象中，disabled的属性是一个布尔类型的属性，值只有<span class="literal">true</span>或者<span class="literal">false</span></span><br></pre></td></tr></table></figure>

<p>【案例：禁用文本框.html】</p>
<p>【案例：设置下拉框选中.html】</p>
<p>【案例：仿京东搜索文本框案例.html】</p>
<p>获得焦点与失去焦点案例</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">onfocus:获得焦点时触发</span><br><span class="line">onblur:失去焦点时触发</span><br></pre></td></tr></table></figure>

<p>【案例：表格全选案例.html】</p>
<h1 id="样式操作（style属性）"><a href="#样式操作（style属性）" class="headerlink" title="样式操作（style属性）"></a>样式操作（style属性）</h1><blockquote>
<p>标签不仅可以通过class属性操作样式，还可以通过style属性操作样式。同样的DOM对象可以通过className操作样式，也可以通过style属性操作样式。</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//1. style属性是一个对象，里面存储了所有行内样式对应的键值对。</span></span><br><span class="line"><span class="comment">//2. 如果样式的名字带了-，比如background-color,到了style对象中，变成了驼峰命名法，backgroundColor（因为-在js中不是一个合法的标识符）</span></span><br><span class="line"><span class="comment">//3. style属性只能获取和设置行内样式，在类样式中定义的样式通过style获取不到。</span></span><br></pre></td></tr></table></figure>

<p><strong>style设置的样式是行内样式，因此优先级要高于className设置的样式</strong></p>
<h2 id="document常用属性："><a href="#document常用属性：" class="headerlink" title="document常用属性："></a>document常用属性：</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> <span class="built_in">document</span>.body  : body比较常用，并且在页面中时唯一的，因此可以使用<span class="built_in">document</span>.body直接获取。</span><br><span class="line"><span class="number">2.</span> <span class="built_in">document</span>.documentElement  : 可以获取html元素</span><br><span class="line"><span class="number">3.</span> <span class="built_in">document</span>.head :  可以直接获取head元素</span><br><span class="line"><span class="number">4.</span> <span class="built_in">document</span>.title :  可以直接获取title的文本</span><br></pre></td></tr></table></figure>

<p>【案例：百度换肤】</p>
<h1 id="tab栏案例"><a href="#tab栏案例" class="headerlink" title="tab栏案例"></a>tab栏案例</h1><blockquote>
<p>排他思想：干掉所有人，复活我自己</p>
</blockquote>
<p>【案例：排他思想.html】</p>
<p>【案例：获取当前元素的索引.html】</p>
<p>【案例：tab栏切换.html】</p>
<h1 id="获取元素的方法"><a href="#获取元素的方法" class="headerlink" title="获取元素的方法"></a>获取元素的方法</h1><h2 id="根据id获取"><a href="#根据id获取" class="headerlink" title="根据id获取"></a>根据id获取</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//参数：元素的id</span></span><br><span class="line"><span class="comment">//返回值：一个元素，如果id不存在，返回null</span></span><br><span class="line"><span class="built_in">document</span>.getElementById(<span class="string">"id"</span>);</span><br></pre></td></tr></table></figure>

<h2 id="根据标签名获取"><a href="#根据标签名获取" class="headerlink" title="根据标签名获取"></a>根据标签名获取</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//参数：标签名</span></span><br><span class="line"><span class="comment">//返回值：伪数组，无论有几个元素，返回都是伪数组</span></span><br><span class="line"><span class="built_in">document</span>.getElementsByTagName(<span class="string">"tagName"</span>);</span><br><span class="line">box.getElementsByTagName(<span class="string">"tagName"</span>);</span><br></pre></td></tr></table></figure>

<h2 id="根据类名获取"><a href="#根据类名获取" class="headerlink" title="根据类名获取"></a>根据类名获取</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//参数：字符串类型的类名</span></span><br><span class="line"><span class="comment">//返回值：伪数组</span></span><br><span class="line"><span class="built_in">document</span>.getElementsByClassName(<span class="string">"class"</span>)</span><br></pre></td></tr></table></figure>

<p><strong>注意：这个方法ie678不支持</strong></p>
<h2 id="根据name获取"><a href="#根据name获取" class="headerlink" title="根据name获取"></a>根据name获取</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//只适用于表单元素</span></span><br><span class="line"><span class="keyword">var</span> ps = <span class="built_in">document</span>.getElementsByName(<span class="string">"aa"</span>);</span><br></pre></td></tr></table></figure>

<h2 id="根据css选择器获取"><a href="#根据css选择器获取" class="headerlink" title="根据css选择器获取"></a>根据css选择器获取</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//参数：是一个css选择器，，   如果是类选择器，  .demo   如果是id选择器：  #aa</span></span><br><span class="line"><span class="comment">//返回值：只会返回一个对象，如果有很多个，会返回第一个</span></span><br><span class="line">document.querySelector();</span><br><span class="line"></span><br><span class="line"><span class="comment">//参数：是一个css选择器</span></span><br><span class="line"><span class="comment">//返回值：会返回伪数组，不管有多少个，都会返回伪数组</span></span><br><span class="line">document.querySelectorAll();</span><br></pre></td></tr></table></figure>



<h1 id="标签的自定义属性"><a href="#标签的自定义属性" class="headerlink" title="标签的自定义属性"></a>标签的自定义属性</h1><blockquote>
<p>我们之前讨论的属性，都是HTML规范中，标签本来就有的属性，对于标签自定义的一些属性，比较特殊。</p>
</blockquote>
<p>在html页面中，定义一个自定义属性</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"box"</span> <span class="attr">aa</span>=<span class="string">"bb"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>在对应的DOM对象中是不存在的，在DOM对象中只会存在固定的那些属性。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> box = <span class="built_in">document</span>.getElementById(<span class="string">"box"</span>);</span><br><span class="line"><span class="built_in">console</span>.log(box.aa);<span class="comment">//undefined</span></span><br></pre></td></tr></table></figure>

<p><strong>attribute方法</strong></p>
<blockquote>
<p>attribute系列方法用于设置标签的属性，不管是自定义的还是固有的属性。</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F;获取标签的属性</span><br><span class="line">box.getAttribute(name);</span><br><span class="line">&#x2F;&#x2F;设置标签的属性</span><br><span class="line">box.setAttribute(name, value);</span><br><span class="line">&#x2F;&#x2F;移除标签的属性</span><br><span class="line">box.removeAttribute(name);</span><br></pre></td></tr></table></figure>


      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://dttx123.gitee.io/2016/06/13/webAPI/01/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.jpg">
      <meta itemprop="name" content="大春哥">
      <meta itemprop="description" content="IT">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Starry Night">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2016/06/13/webAPI/01/" class="post-title-link" itemprop="url">webAPI 01</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2016-06-13 00:00:00" itemprop="dateCreated datePublished" datetime="2016-06-13T00:00:00+08:00">2016-06-13</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-05-13 11:24:55" itemprop="dateModified" datetime="2020-05-13T11:24:55+08:00">2020-05-13</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="什么是WebApi"><a href="#什么是WebApi" class="headerlink" title="什么是WebApi"></a>什么是WebApi</h2><p>API（Application Programming Interface,应用程序编程接口）,API是一些预先定义的方法，这些方法能够实现某些特定的功能，我们无须知道这些API的实现方式，但是我们需要知道这些API如何使用。</p>
<ul>
<li>任何开发语言都会提供自己的API</li>
<li>API的特征输入和输出(参数/返回值)</li>
</ul>
<p>通俗的讲，API就是编程语言给我提供的一些工具，通过这些工具，我们可以非常轻易的完成一些功能。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">做饭需要一套做饭的工具：锅碗瓢盆</span><br><span class="line">打仗需要一套打仗的工具：刀枪剑戟</span><br><span class="line">找对象需一套找对象的工具：钱权颜缘</span><br><span class="line"></span><br><span class="line">Web API: 浏览器提供的一套操作网页（web）的API（方法），通过这套API我们可以非常轻易的操作页面的元素和浏览器的一些功能。</span><br></pre></td></tr></table></figure>

<p><strong>思考：我们学习Web API，我们该学什么？</strong> </p>
<p><img src="/blog/2016/06/13/webAPI/01/javascript.png" alt></p>
<p><strong>ECMAScript - JavaScript的核心</strong></p>
<p>定义了JavaScript 的语法规范</p>
<p>JavaScript的核心，描述了语言的基本语法和数据类型，ECMAScript是一套标准，定义了一种语言的标准。与具体实现无关</p>
<p><strong>BOM - 浏览器对象模型</strong></p>
<p>一套操作浏览器功能的API</p>
<p>通过BOM可以操作浏览器窗口，比如：弹出框、控制浏览器跳转、获取分辨率等 </p>
<p><strong>DOM - 文档对象模型</strong></p>
<p>一套操作页面元素的API</p>
<p>DOM可以把HTML看做是文档树，通过DOM提供的API可以对树上的节点进行操作</p>
<h1 id="DOM-文档对象模型"><a href="#DOM-文档对象模型" class="headerlink" title="DOM-文档对象模型"></a>DOM-文档对象模型</h1><h2 id="DOM基本概念"><a href="#DOM基本概念" class="headerlink" title="DOM基本概念"></a>DOM基本概念</h2><blockquote>
<p>DOM（Document Object Model）文档对象模型，是<code>W3C组织</code>推荐的一套用于处理<code>HTML</code>的标准<code>编程接口</code>。</p>
</blockquote>
<p>DOM又称为文档树模型，因为整个HTML文档是一个树形的结构</p>
<p><img src="/blog/2016/06/13/webAPI/01/1.png" alt></p>
<p>DOM中常见的概念</p>
<ul>
<li>文档<code>document</code>：一个网页可以称为文档</li>
<li>节点<code>node</code>：网页中的所有内容都是节点（标签、属性、文本、注释等）</li>
<li>元素<code>element</code>：网页中的标签</li>
</ul>
<h2 id="DOM初体验"><a href="#DOM初体验" class="headerlink" title="DOM初体验"></a>DOM初体验</h2><blockquote>
<p><code>document.getElementById(&quot;box&quot;)</code>的作用是根据页面中元素的id来获取元素</p>
</blockquote>
<p>在DOM中，想要操作一个元素，首先需要先获取到这个元素才能进行操作。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//功能：通过id获取元素</span></span><br><span class="line"><span class="comment">//参数：字符串类型的id值</span></span><br><span class="line"><span class="comment">//返回值：元素，如果id不存在，会返回null</span></span><br><span class="line"><span class="keyword">var</span> div = <span class="built_in">document</span>.getElementById(<span class="string">'main'</span>);</span><br><span class="line"></span><br><span class="line"><span class="built_in">console</span>.dir(div);</span><br></pre></td></tr></table></figure>

<p>关于<code>console.log</code>和<code>console.dir</code>的区别</p>
<ul>
<li><code>console.log</code>打印一个元素的时候，是以标签的形式进行展示的</li>
<li><code>console.dir</code>打印一个元素的时候，是以对象的形式进行展示的</li>
</ul>
<p>在DOM中，页面标签的属性和DOM对象的属性是一一对应的，因此我们可以通过修改DOM对象的属性来修改标签的属性。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">//html内容</span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">title</span>=<span class="string">"hehe"</span> <span class="attr">id</span>=<span class="string">"box"</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="actionscript"><span class="comment">// javascript代码</span></span></span><br><span class="line"><span class="javascript"><span class="keyword">var</span> div = <span class="built_in">document</span>.getElementById(<span class="string">'box'</span>);</span></span><br><span class="line"><span class="actionscript">div.title = <span class="string">"哈哈"</span>;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"></span><br><span class="line">//结果：div标签的title属性就发生了更改</span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">title</span>=<span class="string">"哈哈"</span> <span class="attr">id</span>=<span class="string">"box"</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h1 id="获取元素"><a href="#获取元素" class="headerlink" title="获取元素"></a>获取元素</h1><h2 id="使用getElementById的注意事项"><a href="#使用getElementById的注意事项" class="headerlink" title="使用getElementById的注意事项"></a>使用getElementById的注意事项</h2><ul>
<li>如果id不存在，会返回null</li>
<li>在DOM中，<code>document.getElementById(&quot;box&quot;)</code>方法需要写在html内容的后面，保证页面加载完成之后才能获取到内容。</li>
<li>部分浏览器，如果元素设置了id属性，可以直接使用（但是不是规范，不推荐）</li>
</ul>
<p><strong>当getElementById返回null的时候，null.onclick就会报错</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!--没有id--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"images/1.jpg"</span> <span class="attr">alt</span>=<span class="string">"图破了"</span> <span class="attr">title</span>=<span class="string">"呵呵"</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="actionscript">  <span class="comment">//如果找不到，返回的是null，试图给null设置属性会报错</span></span></span><br><span class="line"><span class="javascript">  <span class="keyword">var</span> element = <span class="built_in">document</span>.getElementById(<span class="string">"img"</span>);</span></span><br><span class="line"><span class="actionscript">  element.title = <span class="string">"嘿嘿"</span>;<span class="comment">//报错Uncaught TypeError: Cannot set property 'title' of null</span></span></span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><a href="https://developer.mozilla.org/zh-CN/docs/Web/API/Document/getElementById" target="_blank" rel="noopener">mdn地址</a></p>
<h2 id="getElementsByTagName"><a href="#getElementsByTagName" class="headerlink" title="getElementsByTagName"></a>getElementsByTagName</h2><blockquote>
<p>通过标签名获取元素</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//参数：标签名</span></span><br><span class="line"><span class="comment">//返回值：一个伪数组， 伪数组不是数组，不能使用数组的方法，但是可以跟数组一样进行遍历和使用下标进行操作。</span></span><br><span class="line"><span class="keyword">var</span> divs = <span class="built_in">document</span>.getElementsByTagName(<span class="string">'div'</span>);</span><br></pre></td></tr></table></figure>

<p><strong>注意：返回值有没有获取到元素，都是一个伪数组，即便元素只有一个</strong></p>
<h2 id="缩小查找范围"><a href="#缩小查找范围" class="headerlink" title="缩小查找范围"></a>缩小查找范围</h2><ol>
<li><code>document.getElemntsByTagName(&quot;div&quot;)</code>表示获取页面中所有的div元素，范围太大了，可以使用<code>box.getElementsByTagName(&quot;div&quot;)</code>表示获取box中所有的div元素，范围更小。</li>
<li><code>document.getElementById(&quot;demo&quot;)</code>表示获取页面中id为box的元素，没有<code>box.getElementById(&quot;demo&quot;)</code>这种用法。</li>
</ol>
<h1 id="注册事件"><a href="#注册事件" class="headerlink" title="注册事件"></a>注册事件</h1><h2 id="事件的基本使用"><a href="#事件的基本使用" class="headerlink" title="事件的基本使用"></a>事件的基本使用</h2><blockquote>
<p>事件：触发-响应机制</p>
</blockquote>
<p>事件三要素：</p>
<ul>
<li>事件源:触发事件的元素</li>
<li>事件名称: click 点击事件</li>
<li>事件处理程序:事件触发后要执行的代码(函数形式)</li>
</ul>
<p>注册事件的基本语法：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> box = <span class="built_in">document</span>.getElementById(<span class="string">'box'</span>);</span><br><span class="line"><span class="comment">//on:当  click:点击   当按钮被点击的时候触发</span></span><br><span class="line">box.onclick = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="built_in">console</span>.log(<span class="string">'代码会在box被点击后执行'</span>);  </span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<p><strong>注意：事件处理程序并不是立马执行，而是当事件触发的时候在会执行（浏览器会自动调用）</strong></p>
<p>练习：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">点击按钮，切换图片</span><br></pre></td></tr></table></figure>

<h2 id="修改标签的属性"><a href="#修改标签的属性" class="headerlink" title="修改标签的属性"></a>修改标签的属性</h2><blockquote>
<p>在DOM中，页面标签的属性和DOM对象的属性是一一对应的，因此我们可以通过修改DOM对象的属性来修改标签的属性。</p>
</blockquote>
<p>标签的alt，title，src，width，height等属性，可以直接通过对象进行修改。</p>
<p><strong>如果是class属性，在js中class是关键字，因此对应的是className属性</strong></p>
<p>练习：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//1. 点击按钮，修改div的样式 -- 定义类名</span></span><br><span class="line"><span class="comment">//2. 点击按钮，div进行显示和隐藏（两个按钮） -- 预定义类名</span></span><br><span class="line"><span class="comment">//3. 点击按钮，div进行显示和隐藏（一个按钮） -- 预定义类名</span></span><br></pre></td></tr></table></figure>



<p>【案例：二维码案例】</p>
<p>鼠标经过事件与鼠标离开事件</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">onmouseover:当鼠标经过时触发</span><br><span class="line">onmouseout:当鼠标离开时触发</span><br></pre></td></tr></table></figure>



<h2 id="事件中的this"><a href="#事件中的this" class="headerlink" title="事件中的this"></a>事件中的this</h2><blockquote>
<p>当在事件中表示当前元素的时候，可以使用this</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> btn = <span class="built_in">document</span>.getElementById(<span class="string">"btn"</span>);</span><br><span class="line">btn.onclick = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="comment">//给 btn注册的事件，因此this表示btn</span></span><br><span class="line">  <span class="keyword">this</span>.value = <span class="string">"哈哈"</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>练习：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//1. 给多个按钮注册点击事件，点击的那个变成红色</span></span><br><span class="line"><span class="comment">//2. 给多个按钮注册点击事件，当点击按钮，显示对应的图片 -- title属性记录图片src</span></span><br></pre></td></tr></table></figure>



<h2 id="阻止a标签跳转"><a href="#阻止a标签跳转" class="headerlink" title="阻止a标签跳转"></a>阻止a标签跳转</h2><blockquote>
<p>对于a标签来说，默认的行为就是进行页面跳转，如果不想让a标签进行跳转，可以在注册事件中使用<code>return false</code></p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> link = <span class="built_in">document</span>.getElementById(<span class="string">"link"</span>);</span><br><span class="line">link.onclick = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">  alert(<span class="string">"呵呵"</span>);</span><br><span class="line">  <span class="comment">//阻止页面跳转</span></span><br><span class="line">  <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h1 id="标签的内容属性"><a href="#标签的内容属性" class="headerlink" title="标签的内容属性"></a>标签的内容属性</h1><blockquote>
<p>innerText &amp;&amp; innerHTML</p>
</blockquote>
<h2 id="美女相册案例"><a href="#美女相册案例" class="headerlink" title="美女相册案例"></a>美女相册案例</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//1. 找对象</span></span><br><span class="line"><span class="keyword">var</span> imgs = <span class="built_in">document</span>.getElementById(<span class="string">"imgs"</span>);<span class="comment">//ul</span></span><br><span class="line"><span class="keyword">var</span> links = imgs.getElementsByTagName(<span class="string">"a"</span>);<span class="comment">//所有的a标签</span></span><br><span class="line"><span class="keyword">var</span> bigImg = <span class="built_in">document</span>.getElementById(<span class="string">"bigImg"</span>);<span class="comment">//大图片</span></span><br><span class="line"><span class="keyword">var</span> des = <span class="built_in">document</span>.getElementById(<span class="string">"des"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">//2. 给所有的a标签注册点击事件</span></span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; links.length; i++) &#123;</span><br><span class="line">  links[i].onclick = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//3. 修改大图片的src属性， this.href</span></span><br><span class="line">    bigImg.src = <span class="keyword">this</span>.href;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//4. 修改p标签的内容, innerText:内部的文本</span></span><br><span class="line">    des.innerText = <span class="keyword">this</span>.title;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//5. 阻止a跳转</span></span><br><span class="line">    <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://dttx123.gitee.io/2015/01/01/hexo/hexo%E9%85%8D%E7%BD%AE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.jpg">
      <meta itemprop="name" content="大春哥">
      <meta itemprop="description" content="IT">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Starry Night">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2015/01/01/hexo/hexo%E9%85%8D%E7%BD%AE/" class="post-title-link" itemprop="url">hexo</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2015-01-01 00:00:00" itemprop="dateCreated datePublished" datetime="2015-01-01T00:00:00+08:00">2015-01-01</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-05-13 23:39:21" itemprop="dateModified" datetime="2020-05-13T23:39:21+08:00">2020-05-13</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/hexo/" itemprop="url" rel="index"><span itemprop="name">hexo</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>参考： <a href="https://www.jianshu.com/p/3a05351a37dc" target="_blank" rel="noopener">https://www.jianshu.com/p/3a05351a37dc</a><br>参考： <a href="https://www.jianshu.com/p/84ae2ba1c133" target="_blank" rel="noopener">https://www.jianshu.com/p/84ae2ba1c133</a></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/blog/page/3/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/blog/">1</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/3/">3</a><span class="page-number current">4</span>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="大春哥"
      src="/blog/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">大春哥</p>
  <div class="site-description" itemprop="description">IT</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/blog/archives/">
        
          <span class="site-state-item-count">35</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/blog/categories/">
          
        <span class="site-state-item-count">11</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/blog/tags/">
          
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">大春哥</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/blog/lib/anime.min.js"></script>
  <script src="/blog/lib/velocity/velocity.min.js"></script>
  <script src="/blog/lib/velocity/velocity.ui.min.js"></script>

<script src="/blog/js/utils.js"></script>

<script src="/blog/js/motion.js"></script>


<script src="/blog/js/schemes/pisces.js"></script>


<script src="/blog/js/next-boot.js"></script>




  




  
<script src="/blog/js/local-search.js"></script>













  

  

</body>
</html>
